package com.mianshi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class yongyou2 {
    public static void main(String[] args) {
        int[] arr = {10,25,19,37,75,65,27,29,16,9,5,1};
        int[] ans = getSpacialNum(0,arr);
        for(int item : ans){
            System.out.println(item);
        }
    }

    public static int[] getSpacialNum (int num, int[] arr) {
        // write code here
        Arrays.sort(arr);
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < arr.length-1; i++){
            for(int j = i+1; j < arr.length; j++){
                int cha = arr[j]-arr[i];
                if(cha == num){
                    list.add(arr[j]+arr[i]);
                    continue;
                }
            }
        }
        int[] res = list.stream().mapToInt(Integer::intValue).toArray();
//        Arrays.sort(res);
        if(res.length == 0) return new int[]{0};
        return res;
    }
}
